import axios from "axios";
import type { AxiosRequestConfig } from "./types";
import { AxiosInstance } from "axios";
import { RequestHandler } from "./types";

/**
 *
 * @param config {AxiosRequestConfig}
 * @return {RequestHandler}
 */
const createAxiosServiceHandler = (
  config: AxiosRequestConfig
): RequestHandler => {
  const service: AxiosInstance = axios.create(config);
  const handler: RequestHandler = new RequestHandler(service);
  return handler;
};

export { createAxiosServiceHandler };
